<?php
require('../cofd/common.php');
$userid = $_GET['userid'];
$plnr = $_GET['plnr'];
$postid = $_GET['postid'];
$timenow = date("Y-m-d H:i:s");
$sql = "INSERT INTO `comments` (`comment`, `created_at`, `post_id`, `user_id`) VALUES ('{$plnr}', '{$timenow}', '{$postid}', '{$userid}')";
if($conn->query($sql)){
    $response = ['type' => 'success', 'message' => '评论成功'];
}else{
    $response = ['type' => 'error', 'message' => '评论失败'];
}
$conn->close();
header('Content-Type: application/json');
echo json_encode($response, JSON_PRETTY_PRINT);